<!DOCTYPE html>
<html lang="en">

<head>
    <#include "/lx/admin/components/meta.html" />
    <title>证书信息统计 ${metaTitleSuffix!}</title>
    <#include "/lx/admin/components/stylesheets.html" />
</head>

<body>
    <div id="app">
        <el-container>
            <#assign menuIndex="6-5" />
            <#include "/lx/admin/components/menu.html" />
            <el-container>
                <#include "/lx/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-row>
                            <el-col :span="12">
                                <div class="title theme-color1">证书信息统计</div>
                            </el-col>
                        </el-row>
                        <div class="search">
                            <el-date-picker v-model="dateRange" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" unlink-panels="true" :default-value="new Date">
                            </el-date-picker>
                            <el-select v-model="schoolId" clearable filterable placeholder="大学">
                                <el-option v-for="item in schools" :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select>
                            <el-select v-model="companyId" clearable filterable placeholder="公司">
                                <el-option v-for="item in companies" :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select><br />
                            <el-select v-model="selectedProvince" clearable filterable placeholder="省份" @change="onProvinceChange">
                                <el-option v-for="(item, index) in cityArray" :key="index" :label="item.label" :value="item.value">
                                </el-option>
                            </el-select>
                            <el-select v-model="selectedCity" clearable filterable placeholder="市县">
                                <el-option v-for="(item, index) in childrenCityArray" :key="index" :label="item.label" :value="item.value">
                                </el-option>
                            </el-select>
                            <el-select v-model="certId" clearable filterable placeholder="证书">
                                <el-option v-for="(item, index) in certs" :key="index" :label="item.title" :value="item.id">
                                </el-option>
                            </el-select>
                            <el-select v-model="status" clearable filterable placeholder="培训状态">
                                <el-option label="已获得证书" value="1">
                                </el-option>
                                <el-option label="学习中" value="0">
                                </el-option>
                            </el-select>
                            <el-button @click="onSearch"><i class="el-icon-search"></i>筛选</el-button>
                            <el-button @click="goDownload"><i class="el-icon-download"></i>下载</el-button>
                        </div>
                        <el-table ref="multipleTable" :data="list" tooltip-effect="dark" :stripe='true' style="width: 100%">
                            <el-table-column prop="userName" label="姓名">
                                <template slot-scope="scope">
                                    <el-button type="text" @click="goUserInfo(scope.row)">{{ scope.row.userName }}</el-button>
                                </template>
                            </el-table-column>
                            <el-table-column prop="schoolName" label="大学">
                            </el-table-column>
                            <el-table-column prop="certTitle" label="证书名称">
                            </el-table-column>
                            <el-table-column prop="province" label="省份">
                            </el-table-column>
                            <el-table-column prop="city" label="城市">
                            </el-table-column>
                            <el-table-column prop="companyName" label="公司名">
                            </el-table-column>
                            <el-table-column prop="lastStudyTime" label="最后学习时间">
                            </el-table-column>
                            <el-table-column prop="lastExamTime" label="最后考试时间">
                            </el-table-column>
                            <el-table-column prop="status" label="培训状态">
                                <template slot-scope="scope">
                                    <span v-if="scope.row.status == 1">已获得证书</span>
                                    <span v-if="scope.row.status == 0">学习中</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="passTime" label="获得证书时间">
                            </el-table-column>
                        </el-table>
                        <#include "/lx/admin/components/page.html" />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/lx/admin/components/footer.html" />
    </div>
    <#include "/lx/admin/components/scripts.html" />
    <script type="text/javascript" src="/lx/activity/assets/json/city.json"></script>
    <script>
        var vue = new Vue({
        el: '#app',
        data() {
            return {
                list: [],
                dateRange: '',
                schools: [],
                schoolId: '',
                companies: [],
                companyId: '',
                certs: [],
                certId: '',
                cityArray: city,
                childrenCityArray: [],
                selectedProvince: '',
                selectedCity: '',
                status: ''
            }
        },
        mounted: function() {
            this.schools = ${schools!'[]'}
            var schoolId = '${schoolId!""}'
            if (schoolId != '') {
                this.schoolId = Number(schoolId);
            }
            this.companies = ${companies!'[]'}
            var companyId = '${companyId!""}'
            if (companyId != '') {
                this.companyId = Number(companyId);
            }
            this.certs = ${certs!'[]'}
            var certId = '${certId!""}'
            if (certId != '') {
                this.certId = Number(certId);
            }
            this.selectedProvince = '${province!}'
            this.selectedCity = '${city!}'
            if (this.selectedProvince) {
                for (var i = 0; i < this.cityArray.length; i ++) {
                    if (this.cityArray[i].value == this.selectedProvince) {
                        this.childrenCityArray = this.cityArray[i].children;
                    }
                }
            }
            this.status = '${status!""}'
            var startTime = '${startTime!""}'
            if (startTime != '') {
                this.dateRange = new Array;
                this.dateRange.push('${startTime!}');
                this.dateRange.push('${endTime!}');
            }
        },
        methods: {
            onSearch() {
                var self = this;
                var keys = [
                    { key: 'schoolId', value: self.schoolId },
                    { key: 'companyId', value: self.companyId },
                    { key: 'certId', value: self.certId },
                    { key: 'province', value: self.selectedProvince },
                    { key: 'city', value: self.selectedCity },
                    { key: 'status', value: self.status }
                ]
                if (self.dateRange != null && self.dateRange.length > 1) {
                    keys.push({ key: 'startTime', value: self.dateRange[0] });
                    keys.push({ key: 'endTime', value: self.dateRange[1] });
                } else {
                    keys.push({ key: 'startTime', value: '' });
                    keys.push({ key: 'endTime', value: '' });
                }
                goPage(1, keys);
            },
            onProvinceChange(val) {
                this.selectedCity = '';
                this.childrenCityArray = new Array;
                for (var i = 0; i < this.cityArray.length; i ++) {
                    if (this.cityArray[i].value == val) {
                        this.childrenCityArray = this.cityArray[i].children;
                    }
                }
            },
            goUserInfo(item) {
                window.location.href = "/lx/admin/user/info?userId=" + item.userId;
            }
        }
    })
    </script>
    <script>
        vue.list = ${items!'[]'}
    </script>
    <#include "/lx/admin/components/msg.html" />
    <style type="text/css">
    .title {
        font-size: 18px;
        font-weight: bold;
    }

    .operations {
        text-align: right;
    }

    .search {
        margin-top: 10px;
    }
    </style>
</body>

</html>